﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

using Read.Models;
using Read.Services;
using Read.Utility;

namespace Read.Web.Api
{
    /// <summary>
    /// 用户操作API
    /// </summary>
    public class MemberController : ApiBaseApiController
    {
        /// <summary>
        /// 用户注册(Swagger API文档示例)
        /// </summary>
        [Route("Api/Member/Login")]
        [HttpPost]
        public ResultData<String> Login([FromBody]PostLogin model)
        {
            var res = new ResultData<String>()
            {
                Data = "你刚刚提交的信息：" + model.ToJson(),
                Message = "登录成功"
            };
            return res;
        }

        /// <summary>
        /// 用户登录(Swagger API文档示例)
        /// </summary>
        [Route("Api/Member/Register")]
        [HttpPost]
        public ResultData<String> Register([FromBody]PostRegister model)
        {
            var res = new ResultData<String>()
            {
                Data = "你刚刚提交的信息：" + model.ToJson(),
                Message = "注册成功"
            };
            return res;
        }

        /// <summary>
        /// 快捷登陆(Swagger API文档示例)
        /// </summary>
        [Route("Api/Member/QuickLogin")]
        [HttpPost]
        public ResultData<ResultToken> QuickLogin([FromBody]PostQuickLogin model)
        {
            var token = new ResultToken()
            {
                Id = 1,
                Cellphone = "18617089812",
                Name = "测试用户",
                Token = "d50f2bb3ff7bc9a9e04c45483809267d",
                Sex = 1,
                HeadImg = "uploads/171106/1711066DF7537D7BD7F707AB674C9C8EB20F20.jpg"
            };
            var res = new ResultData<ResultToken>()
            {
                Data = token,
                Result = true,
                Message = "快捷登陆成功，你刚刚提交的信息：" + model.ToJson(),
            };
            return res;
        }
    }
}
